package cn.cttic.app.api.enums;

import cn.cttic.common.core.exception.base.BaseException;
import cn.cttic.common.core.exception.user.UserException;
import lombok.Getter;

@Getter
public enum SaleOrderStatus {

    WAITING("未安装", 0),
    INSTALLED("已安装", 1),
    ACCEPTED("已验收", 2),
    VERIFICATED("已核销", 3),
    CANCELED("已取消", 9)
    ;

    private final String label;
    private final Integer value;

    SaleOrderStatus(String label, Integer value) {
        this.label = label;
        this.value = value;
    }

    public static SaleOrderStatus of(Integer value) {
        for (SaleOrderStatus type : SaleOrderStatus.values()) {
            if (type.value == value) {
                return type;
            }
        }
        throw new BaseException("订单状态类型未匹配");
    }
}
